package cn.yl.ad.server.service.impl;

import cn.yl.ad.server.entity.PromotionAd;
import cn.yl.ad.server.mapper.PromotionAdMapper;
import cn.yl.ad.server.service.PromotionAdService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 广告表 服务实现类
 * </p>
 *
 * @author yl
 * @since 2022-04-22
 */
@Service
public class PromotionAdServiceImpl extends ServiceImpl<PromotionAdMapper, PromotionAd> implements PromotionAdService {

    @Override
    public List<PromotionAd> getAdsBySpaceId(Integer spaceId) {
        QueryWrapper<PromotionAd> wrapper = new QueryWrapper<>();
        wrapper.eq("space_id", spaceId);
        wrapper.orderByDesc("priority");
        List<PromotionAd> list = this.list(wrapper);
//        list.forEach(promotionAd ->
//                promotionAd.setImg("https://yl-ada.oss-cn-beijing.aliyuncs.com"+promotionAd.getImg()));
        return list;
    }
}
